package stack;

import java.util.ArrayList;

public class LCR027 {
}

class test2 {
    public boolean isPalindrome(ListNode head) {
        ArrayList<Integer> arrayList=new ArrayList<>();
        while(head!=null){
            arrayList.add(head.val);
            head=head.next;
        }
        int length=arrayList.size();
        for(int i=0,j=length-1;i<length&&j>=0;j--,i++){
            if(arrayList.get(i)!=arrayList.get(j)){
                return false;
            }
        }
        return true;
    }
}
